﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace CloudPms.Common.Log
{
    /// <summary>
    /// 日志类别编码
    /// <para>--------------------------</para>
    /// <para>获取方法：</para>
    /// <para>  例如：取房间信息变更日志 Log表中CategoryID - 100 结果小余100  </para>
    /// <para>  例如：取定单变更的日志 Log表中CategoryID - 210 结果小余10  </para>
    /// <para>--------------------------</para>
    /// <para>@Author: cnalexi@gmail.com</para> 
    /// <para>@Create: 2012/4/2</para> 
    /// </summary>
    public static class LogCategory
    {
        #region ☆ -------- 1 房间信息 -------- ☆

        /// <summary>
        /// 房态变更 - ALL
        /// </summary>
        public const int RoomStatus = 110;

        /// <summary>
        /// 房态变更 - 维修房
        /// </summary>
        public const int RoomStatusOOO = 111;

        /// <summary>
        /// 房间基本信息 - ALL
        /// </summary>
        public const int RoomInfo = 120;

        /// <summary>
        /// 属性修改 - ALL
        /// </summary>
        public const int RoomAttribute = 130;

        /// <summary>
        /// 属性修改 - 锁房
        /// </summary>
        public const int RoomAttributeLock = 131;

        /// <summary>
        /// 房间描述 - ALL
        /// </summary>
        public const int RoomDescription = 140;

        #endregion

        #region ☆ -------- 2 订单定单 -------- ☆

        /// <summary>
        /// 订单变更
        /// </summary>
        public const int Order = 210;

        /// <summary>
        /// 散客入住
        /// </summary>
        public const int OrderCheckIn = 211;
        
        /// <summary>
        /// 住单修改
        /// </summary>
        public const int OrderEdit = 213;

        /// <summary>
        /// 在住单换房
        /// </summary>
        public const int OrderChangeRoom = 214;

        /// <summary>
        /// 设置团队/关联主单
        /// </summary>
        public const int OrderSetMaster = 215;

        /// <summary>
        /// 重新入住
        /// </summary>
        public const int ReCheckIn = 216;

        /// <summary>
        /// 订单退房
        /// </summary>
        public const int CheckOut = 217;

        /// <summary>
        /// 预订单新增
        /// </summary>
        public const int Reservation = 220;

        /// <summary>
        /// 预订单变更
        /// </summary>
        public const int ReservationEdit = 221;

        /// <summary>
        /// NoShow
        /// </summary>
        public const int ReservationNoShow = 223;

        /// <summary>
        /// 预订取消
        /// </summary>
        public const int ReservationCancel = 224;

        /// <summary>
        /// 预订恢复
        /// </summary>
        public const int ReservationRecover = 225;

        /// <summary>
        /// 预订排房
        /// </summary>
        public const int ReservationAssigned = 226;

        #endregion

        #region ☆ -------- 3 收银账目 -------- ☆

        /// <summary>
        /// 账目 - All
        /// </summary>
        public const int Account = 310;

        /// <summary>
        /// 账目 - 添加主账单
        /// </summary>
        public const int AccountAdd = 311;

        /// <summary>
        /// 账目 - 结账
        /// </summary>
        public const int AccountClose = 312;

        /// <summary>
        /// 账目 - 临时挂账
        /// </summary>
        public const int AccountCityLedger = 313;

        /// <summary>
        /// 账目 - 添加借方账单
        /// </summary>
        public const int BillAddCredit = 321;

        /// <summary>
        /// 账目 - 添加贷方账单
        /// </summary>
        public const int BillAddDebit = 322;

        /// <summary>
        /// 账目 - 冲销账单
        /// </summary>
        public const int BillStrike = 323;

        /// <summary>
        /// 账目 - 调整账目
        /// </summary>
        public const int BillAdjust = 324;

        #endregion

        #region ☆ -------- 7 夜审相关 -------- ☆

        /// <summary>
        /// 夜审 - All
        /// </summary>
        public const int NightAudit = 710;

        /// <summary>
        /// 夜审完成 - 有酒店
        /// </summary>
        public const int NaComplete = 711;

        /// <summary>
        /// 夜审完成 - 无酒店
        /// </summary>
        public const int NaNullComplete = 712;

        /// <summary>
        /// 夜审异常
        /// </summary>
        public const int NightAuditException = 713;

        #endregion

        #region ☆ -------- 8 会员 & 早餐 -------- ☆

        /// <summary>
        /// 会员信息
        /// </summary>
        public const int MemberInfo = 810;

        /// <summary>
        /// 会员积分
        /// </summary>
        public const int MemberPoint = 820;

        /// <summary>
        /// 积分兑换早餐
        /// </summary>
        public const int PointExchangeBreakfast = 821;

        /// <summary>
        /// 积分兑换早餐
        /// </summary>
        public const int PointExchangeRoom = 822;

        /// <summary>
        /// 早餐信息
        /// </summary>
        public const int Breakfast = 850;

        /// <summary>
        /// 售卖早餐
        /// </summary>
        public const int BreakfastSale = 851;

        /// <summary>
        /// 赠送早餐
        /// </summary>
        public const int BreakfastGive = 852;

        #endregion

        #region ☆ -------- 9 基本信息 -------- ☆

        /// <summary>
        /// 配置
        /// </summary>
        public const int Option = 910;

        /// <summary>
        /// 登录
        /// </summary>
        public const int LoginLog = 911;

        /// <summary>
        /// 打印日志
        /// </summary>
        public const int PrintLog = 912;

        #endregion

        private static IDictionary<int, string> BuildCategory()
        {
            IDictionary<int, string> dict = new Dictionary<int, string>();

            #region 房态

            dict.Add(RoomStatus, "变更房态");
            dict.Add(RoomStatusOOO, "维修房间");
            dict.Add(RoomInfo, "变更房间信息");
            dict.Add(RoomAttribute, "变更房间属性");
            dict.Add(RoomAttributeLock, "临时锁房");
            dict.Add(RoomDescription, "变更房间描述");

            #endregion

            #region 订单

            dict.Add(Order, "订单信息");
            dict.Add(OrderCheckIn, "订单入住");
            dict.Add(OrderEdit, "订单修改");
            dict.Add(OrderChangeRoom, "订单换房");
            dict.Add(OrderSetMaster, "设置主单");
            dict.Add(ReCheckIn, "重新入住");
            dict.Add(CheckOut, "订单退房");
            dict.Add(Reservation, "预订信息");
            dict.Add(ReservationEdit, "预订修改");
            dict.Add(ReservationNoShow, "预订NoShow");
            dict.Add(ReservationCancel, "预订取消");
            dict.Add(ReservationRecover, "预订恢复");
            dict.Add(ReservationAssigned, "预订排房");
            
            #endregion

            #region 收银

            dict.Add(Account, "账目信息");
            dict.Add(AccountAdd, "添加主账单");
            dict.Add(AccountClose, "结账");
            dict.Add(AccountCityLedger, "临时挂账");
            dict.Add(BillAddCredit, "添加主账单");
            dict.Add(BillAddDebit, "添加主账单");
            dict.Add(BillStrike, "冲账");
            dict.Add(BillAdjust, "调账");

            #endregion

            #region 夜审

            dict.Add(NightAudit, "夜审信息");
            dict.Add(NaComplete, "夜审成功");
            dict.Add(NaNullComplete, "夜审成功无酒店");
            dict.Add(NightAuditException, "夜审异常");

            #endregion

            #region 会员 & 早餐

            dict.Add(MemberInfo, "会员信息");
            dict.Add(MemberPoint, "会员积分");
            dict.Add(PointExchangeBreakfast, "积分兑换早餐");
            dict.Add(PointExchangeRoom, "积分兑换免房");
            dict.Add(Breakfast, "早餐信息");
            dict.Add(BreakfastSale, "售卖早餐");
            dict.Add(BreakfastGive, "赠送早餐");

            #endregion

            #region 配置

            dict.Add(Option, "配置信息");

            dict.Add(LoginLog, "登录记录");

            dict.Add(PrintLog, "打印日志");

            #endregion

            return dict;
        }

        private static volatile IDictionary<int, string> _categoryDict = null;

        private static readonly object locker = new object();
        
        /// <summary>
        /// 类别属性
        /// </summary>
        public static IDictionary<int, string> CategoryDict
        {
            get
            {
                if(_categoryDict==null)
                {
                    lock(locker)
                    {
                        if(_categoryDict==null)
                        {
                            _categoryDict = BuildCategory();

                            Thread.MemoryBarrier();
                        }
                    }
                }

                return _categoryDict;
            }
        }

        /// <summary>
        /// 获取日志类别名称
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public static string GetCategoryName(int category)
        {
            if (CategoryDict.ContainsKey(category))
            {
                return CategoryDict[category];
            }

            return string.Empty;
        }
    }
}
